import django
import os

from django.conf.urls import url
from rest_framework.routers import SimpleRouter

from oplatform.channels.device_info import DeviceInfoRealTimeInfoConsumer
from oplatform.channels.ping import PingTimeInfoConsumer
from oplatform.channels.scan_channel import ScanChannelTimeInfoConsumer
from oplatform.viewsets.channel import ChannelViewSet
from oplatform.viewsets.oplatform import MenuViewSet, ConfigurationViewSet, MachineCodeViewSet
from oplatform.viewsets.user import UserViewSet

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

django.setup()

router = SimpleRouter()

router.register('user', UserViewSet)
router.register('menu', MenuViewSet)
router.register('channel', ChannelViewSet)
router.register('config', ConfigurationViewSet)
router.register('register', MachineCodeViewSet)
urlpatterns = router.urls

device_channel_urls = [
    url('/device/real_time_info/', DeviceInfoRealTimeInfoConsumer),
    url('/device/ping/', PingTimeInfoConsumer),
    url('/device/scan_channel/', ScanChannelTimeInfoConsumer),
]

